const inquirer = require('inquirer')
const chalk = require('chalk')

const {
  gitUrl
} = require('./template')
const generate = require('./generate')

chalk.level = 3

// 定制化项目信息
module.exports = () => {
  inquirer.prompt([{
    type: 'input', 
    message: 'your  projectName:', 
    name: 'projectName', 
    validate: (val) => {
      if (val === "") {
        return chalk.red('项目名不能为空，请重新输入')
      }
      return true
    }
  }]).then(answer => {
    console.log(chalk.green('开始初始化文件\n'))
    console.log(chalk.gray('初始化中...'))
    generate(gitUrl, answer.projectName)
  })
}